package org.jeecg.modules.simulator.service;

import lombok.Getter;
import org.jeecg.modules.simulator.jsonot.RouteStation;

import org.jeecg.modules.simulator.jsonot.T80RoutOD;
import org.jeecg.modules.simulator.mapper.T80RouteODMapper;
import org.jeecg.modules.simulator.mapper.T80RouteStationMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

/**
 * @program: simulator-b20240918
 * @description:
 * @author: renzhg
 * @create: 2024-10-07 17:01
 **/
@Service
public class T80RouteHisService {

    @Resource
    T80RouteStationMapper t80RouteHisMapper;

    @Resource
    T80RouteODMapper t80RouteODMapper;


    @Getter
    Map<String, List<RouteStation>> t80RouteHisMap=new HashMap<>();
    @Getter
    Map<String, List<T80RoutOD>> t80ODRouteMap=new HashMap<>();


    public void load(){
        try {
            List<RouteStation> t80RouteHisList=t80RouteHisMapper.queryRoutes();

            t80RouteHisMap=t80RouteHisList.stream().collect(java.util.stream.Collectors.groupingBy(e -> e.getRouteId()));
            t80RouteHisMap.forEach((k,v)->{
//            System.out.println(k);
                v.sort(Comparator.comparing(RouteStation::getStationSn));
            });
            List<T80RoutOD> t80RoutODSList = t80RouteODMapper.queryODRoutes();

            t80ODRouteMap=t80RoutODSList.stream().collect(java.util.stream.Collectors.groupingBy(e -> e.getOdKey()));


        } catch (Exception e) {
            e.printStackTrace();
        }



    }



}
